package com.ruoyi.web.controller.cinema;

import java.util.List;

import com.ruoyi.common.core.domain.entity.CinemaOrder;
import com.ruoyi.system.service.ICinemaOrderService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单表Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/cinema/order")
public class CinemaOrderController extends BaseController
{
    @Autowired
    private ICinemaOrderService cinemaOrderService;

    /**
     * 查询订单表列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(CinemaOrder cinemaOrder)
    {
        startPage();
        List<CinemaOrder> list = cinemaOrderService.selectCinemaOrderList(cinemaOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单表列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:export')")
    @Log(title = "订单表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CinemaOrder cinemaOrder)
    {
        List<CinemaOrder> list = cinemaOrderService.selectCinemaOrderList(cinemaOrder);
        ExcelUtil<CinemaOrder> util = new ExcelUtil<CinemaOrder>(CinemaOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取订单表详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(cinemaOrderService.selectCinemaOrderById(id));
    }

    /**
     * 新增订单表
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:add')")
    @Log(title = "订单表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CinemaOrder cinemaOrder)
    {
        return toAjax(cinemaOrderService.insertCinemaOrder(cinemaOrder));
    }

    /**
     * 修改订单表
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:edit')")
    @Log(title = "订单表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CinemaOrder cinemaOrder)
    {
        return toAjax(cinemaOrderService.updateCinemaOrder(cinemaOrder));
    }

    /**
     * 删除订单表
     */
    @PreAuthorize("@ss.hasPermi('cinema:order:remove')")
    @Log(title = "订单表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cinemaOrderService.deleteCinemaOrderByIds(ids));
    }
}
